import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

  id?: number,
  SN?: string,
  factoryId?: number,
  productId?: number,
  status?: number,
  modelId?: number,
  licenseUnityId?: number,
  superviseUnityIds?: any,
  endDate?: string,
  modelInfo?: any
  expireDate?: string,
  serveTime?: string,
  unityId?: number,
  file?: File,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/product/serial/v2/serials';
const Url = '/system/product/serial/v2/serial';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};

/** 1.6.1.6产品类型下拉框 */
export const getProductTypeSelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/serial/v2/serial/product', {
    params
  });
}
/** 1.10.1.3产品类型下拉框 无厂家id产品类型下拉框 */
export const getProductNoIDTypeSelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/serial/v2/serial/product', {
    params
  });
}
/** 1.6.1.7产品型号下拉框 */
export const getProductModelSelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/serial/v2/serial/model', {
    params
  });
}
/** 1.6.1.11序列号转移列表 */
export const getTransferList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/serial/v2/list', {
    params
  });
}
/** 1.6.1.12转移序列号 */
export const transferSerial = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/product/serial/v2/transfer', {
    data
  });
}
/** 1.6.1.2导入序列号 */
export const importSerial = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/product/serial/v2/import', {
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}
/** 1.6.3 下载流量卡/序列号导入模板 */
export const downloadTemplate = (params?: object) => {
  return http.request<Blob>("get", '/system/product/v2/temp', {
    params,
    responseType: 'blob'
  });
}



/** 1.1.3.8授权商单位下拉框 */
export const getAuthorizationSelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/serial/v2/serial/license', {
    params
  });
}
/** 1.1.3.9监管单位下拉框 */
export const getSupervisionSelectList = (params?: object) => {
  return http.request<commonResult<Array<any>>>("get", '/system/product/serial/v2/serial/supervise', {
    params
  });
}